package com.yc.cloud.basic.utils;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.val;

import java.util.List;

/**
 * @Description: 自定义分页工具
 * @Author JackGu
 * @Date: 2022/10/2 16:57
 * @Version 1.0
 */
public class PageUtil<T> {


    /**
     * 包装成ipage对象
     * @param list
     * @param pageNum
     * @param pageSize
     * @param count
     * @return
     * @param <T>
     */
    public static <T> IPage<T> convertPage(List<T> list, Integer pageNum,
                                           Integer pageSize, Long count) {
        val page = new Page<T>();
        page.setRecords(list);
        page.setCurrent(pageNum);
        page.setSize(pageSize);
        page.setTotal(count);
        return page;
    }
}
